package Server.Dwc.slhb;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Vector;

import net.sf.json.*;
import redis.protocal.DbInfoMgr;
import redis.protocal.DwcRedisRecord;
import redis.protocal.UserRedisInfo;
import robot.GoldMgr;
import robot.Robot;
import robot.RobotMgr;
import Server.Agent.GameDB;
import Server.Model.Base.IRoom;
import Server.Model.Base.IServerUserItem;
import Server.Model.Base.SHMUser;
import Server.Model.Hall.QpGameMgr;
import Server.Model.Hall.dthall;
import admin.AdminRedis;
import club.ClubRedis;
import common.routine.CommonDef;
import common.routine.PublishDef;
import Server.Model.Base.SecShmUser;
import Server.Model.Base.UserGoldChange;
import Server.Model.Base.UserRmbChange;

class MineInfo{
	public int m_lUid;
	public String m_name;
	public int m_isAndroidUser;
	public double m_redRmb;
	public int m_redNum;
	public int m_leiHao;
	public double m_beishu;
}
class DrawInfo{
	public double m_drawRmb;
	public int m_lUid;
	public String m_name;
	public int m_isAndroidUser;
}
class OpenRedInfo{
	MineInfo m_mineInfo;
	public double m_leftRmb;
	public int m_currnum;
	public int m_getLeiNum;
	public List<DrawInfo> m_drawedInfo = new ArrayList<DrawInfo>();
}

public class SlhbTable extends IRoom {
	@Override
	public int GetID() {
		return m_dwTableID;
	};

	@Override
	public int GetCreator() {
		// TODO Auto-generated method stub
		return m_Creator;
	}
	@Override
	public String GetType() {
		return "SLHB";
	};
	@Override
	public void OnClientClose(int uid) {
		OnUserStandUp(uid,false);
	};

	public boolean SendData(int wChairID, String sData) {
		if (wChairID == Constants.INVALID_CHAIR) {
			for (short i = 0; i < m_pIUserItem.length; i++) {
				if (m_pIUserItem[i].dwUserID > 0) {
					if (m_pIUserItem[i].isAndroidUser == 0) {
						dthall.getInstance().onSend(m_pIUserItem[i].dwUserID, sData);
					} else {
						// mPlayers[i].SendGameMessage(wSubCmdID, pData,
						// wDataSize, data);
					}
				}
			}
			return true;
		} else {
			if (wChairID >= m_pIUserItem.length) {
				dthall.getInstance().onSend(wChairID, sData);
			} else if (m_pIUserItem[wChairID].dwUserID > 0) {
				if (m_pIUserItem[wChairID].isAndroidUser == 0) {
					dthall.getInstance().onSend(m_pIUserItem[wChairID].dwUserID, sData);
				} else {
				}
				return true;
			}
		}

		return false;
	}

	int m_dwLastDoCmdTime;

	public int CanSit(int _Uid) {
		if(this.isDwcType()){
			UserRedisInfo info = dthall.getInstance().getSafeUserRedisInfo(_Uid);
			if(info.json.optInt("userRmbType") == 1 && !canUserJoinRentRoom(info.json.optInt("upAgentUid"))){
				return 22;
			}else if(info.json.optInt("userRmbType") == 0 && m_clubOwnerId != 0){
				UserRedisInfo clubInfo = dthall.getInstance().getSafeUserRedisInfo(m_clubOwnerId);
				if(clubInfo.json.optInt("userRmbType") == 1){
					return 23;
				}
			}
		}
		if (m_locked != 0) {
			return 13;
		}

		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID == _Uid) {
				SUBCMD_S_OnLine cmd = new SUBCMD_S_OnLine();
				cmd.uid = _Uid;
				cmd.seat = i;
				SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
				return i;
			}
		}

		SHMUser user = dthall.getInstance().getUserInfo(_Uid);
		
		if(user != null && isGoldType()){
			if(user.getCoin(0) < m_ruchang){
				return 21;
			}
		}
		if(user != null && isDwcType()){
			if(user.getCoin(0) < m_ruchang){
				return 21;
			}
		}
	
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID == 0) {
				return 1;
			}
		}
		return 12;
	};

	Long m_lStartTime;
	long needDealTime;
	int m_dwTableID;
	long m_dismissTimer;


	boolean m_bGameStarted;
	boolean m_bTableStarted;
	int m_byRound;
	int m_byMaxRound;
	int m_wFaPaiDelay;
	
	
	public String m_payWay;
	public String m_strParam;
	public String m_strRoomDesc;
	public String[] m_vecParam;
	public String m_jinErStr;
	public String m_beiShuStr;
	
	public String m_guize;//扫雷的类型
	
	public int m_byZhuang;

	GameLogic m_GameLogic = new GameLogic();
	String m_curStage;
	
	int m_locked = 0;
	public int m_maxUserNum = 48;
	IServerUserItem m_pIUserItem[] = new IServerUserItem[m_maxUserNum];
	{
		for (int i = 0; i < m_maxUserNum; i++) {
			m_pIUserItem[i] = new IServerUserItem();
		}
	}

	public int m_Creator;
	
	int[] m_UserStatus = new int[m_maxUserNum];
	int UserCntReady = 0;
	long startDealTime = 30;
	int m_needRobotNum = 0;
	public List<MineInfo> m_applyMines = new ArrayList<MineInfo>();
	OpenRedInfo m_currMine = null;
	int m_robotDrawNum = 0;
	int m_realDrawNum = 0;
	boolean m_needRobotDraw = true;
	SlhbTable() {
		m_bTableStarted = false;
		m_lStartTime = System.currentTimeMillis() / 1000;
		m_bRemove = false;
		m_payWay = "FZPAY";
		
		m_guize = "";
		
		m_strParam = "";
		m_strRoomDesc = "";
	}

	public void addFirstRobot(){
		//一次把机器人添加完整
		if(m_clubOwnerId != 0)
			return;
		if(m_needRobotNum == 0){
			m_needRobotNum = random(10,20);
		}
		//机器人申请资金需要
		for(int i = 0;i < m_needRobotNum;i++){
			Robot robot = RobotMgr.getInstance().AllocRobot();
			int robot_uid = robot.uid;
			
			
			SHMUser user = dthall.getInstance().getUserInfo(robot_uid);
			//申请100-500的资金
			double robot_rmb = RobotMgr.getInstance().getRandRobotGold(10,4);
			robot_rmb += Math.random() * 2;
			BigDecimal b = new BigDecimal(robot_rmb);
			robot_rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
			double rmb = GoldMgr.getInstance().applyRobotRmb(robot_rmb);
			if(rmb == 0){
				//申请不到足够rmb
				setNeedRobot(false,0);
				return;
			}
			if(user == null){
				setNeedRobot(false,0);
				return;
			}
			user.setRMb1v1Value(rmb);
			user.setApplyNum(rmb);
			OnUserSit(robot_uid);
		}
		for(int i = 0;i < 10;i++){
			addRobotRed();
		}
	}
	void onRemoveMineForUserLeave(int uid){
		//用户离开或者退出，删除对应的红包
		for(int i = 0;i < m_applyMines.size();i++){
			MineInfo mine = m_applyMines.get(i);
			if(mine.m_lUid == uid){
				m_applyMines.remove(i);
			}
		}
	}
	void addMine(MineInfo mine){
		//按照顺序排列一遍
		if(m_guize.equals("mode1")){
			//大包优先sort
			if(m_applyMines.size() == 0){
				m_applyMines.add(mine);	
			}else{
				boolean add = false;
				for(int i = 0;i < m_applyMines.size();i++){
					MineInfo info = m_applyMines.get(i);
					if(mine.m_redRmb > info.m_redRmb){
						m_applyMines.add(i,mine);
						add = true;
						break;
					}
				}
				if(add == false){
					m_applyMines.add(mine);
				}
			}
		}else{
			m_applyMines.add(mine);			
		}
	}
	public IServerUserItem  getRandRobot(){
		int robotcount = 0;
		for(int i = 0;i < m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 2){
				robotcount++;
			}
		}
		int index = random(0,robotcount);
		int count = 0;
		for(int i = 0;i < m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 2){
				if(count == index){
					return m_pIUserItem[i];
				}
				count++;
			}
		}
		return null;
	}
	void addRobotRed(){
		if(m_clubOwnerId != 0)
			return;
		if(m_applyMines.size() >= 10)
			return;
		//少于10个则添加机器人红包
		IServerUserItem robot = getRandRobot();
		//现金不能太少
		if(robot == null || robot.lUserRmb < 10.0)
			return;
		if(CommonDef.getRandomInt(100) < 2){
			//发个大包
			int maxlimit = 50;
			if(maxlimit > robot.lUserRmb)
				maxlimit = (int)robot.lUserRmb;
			int jiner = random(10,maxlimit);
			if(robot.lUserRmb < jiner){
				return;
			}
			MineInfo mine = new MineInfo();
			mine.m_redRmb = jiner;
			mine.m_isAndroidUser = 2;
			mine.m_lUid = robot.dwUserID;
			mine.m_name = robot.szNickName;
			mine.m_leiHao = CommonDef.getRandomInt(10);
			if(m_guize.equals("mode1")){
				mine.m_redNum = 7;
				mine.m_beishu = 1.5;
			}else if(m_guize.equals("mode2")){
				mine.m_redNum = 10;
				mine.m_beishu = 1;
			}
			addMine(mine);
		}else{
			int jiner = random(10,20);
			if(robot.lUserRmb < jiner){
				return;
			}
			MineInfo mine = new MineInfo();
			mine.m_redRmb = jiner;
			mine.m_isAndroidUser = 2;
			mine.m_lUid = robot.dwUserID;
			mine.m_name = robot.szNickName;
			mine.m_leiHao = CommonDef.getRandomInt(10);
			if(m_guize.equals("mode1")){
				mine.m_redNum = 7;
				mine.m_beishu = 1.5;
			}else if(m_guize.equals("mode2")){
				mine.m_redNum = 10;
				mine.m_beishu = 1;
			}
			addMine(mine);
		}
	}
	void setRedType(String type){
		m_guize = type;
		//mode1,
		//mode2,
		if(m_guize.equals("mode1")){
			m_jinErStr = "10-200元";
			m_beiShuStr = "7包1.5倍";
		}else if(m_guize.equals("mode2")){
			m_jinErStr = "10-500元";
			m_beiShuStr = "10包1倍";
		}
	}
	void Init(int cbReason) {
		m_dwLastDoCmdTime = 0;
		m_bGameStarted = false;
		m_wFaPaiDelay = 0;
		UserCntReady = 0;
		startDealTime = 30;
		if(cbReason == Constants.INIT_TOTAL){
			setRoomStarted(true);//设置为开始状态
			addFirstRobot();//先添加第一批机器人
			m_curStage = "stage_jiesuan";
			currDealTime = 1;
		}
	}

	void KickRobots() {
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].isAndroidUser == 1) {

			}
		}
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].isAndroidUser == 1) {

			}
		}
	}

	boolean HasRobot() {
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].isAndroidUser == 1) {
				return true;
			}
		}
		return false;
	}

	void SendAvatar(int _Uid) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}

		String iter = dthall.getInstance().Handle_OnGetUserAvatar(_Uid);

		SUBCMD_S_Avatar cmd = new SUBCMD_S_Avatar();
		cmd.m_lUid = _Uid;
		if (iter != null) {
			cmd.szAvatarURL = iter;
		} else {
			cmd.szAvatarURL = PublishDef.getDefaultHeadAvatar();
		}

		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());

	}
	public void SendLocationData(SHMUser user) {
		JSONObject data = new JSONObject();
		data.put("loc", user.getGpsLocInfo());
		data.put("uid", user.getUid());
		data.put("command", "GPS_LOC");
		SendData(Constants.INVALID_CHAIR, data.toString());

		for (short i = 0; i < m_pIUserItem.length; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				if (m_pIUserItem[i].isAndroidUser == 0) {
					int uid = m_pIUserItem[i].dwUserID;
					SHMUser other = dthall.getInstance().getUserInfo(uid);
					if(other != null){
						data.put("uid", other.getUid());
						data.put("loc", other.getGpsLocInfo());
						dthall.getInstance().onSend(user.getUid(), data.toString());
					}
				}
			}
		}
	}

	public void SendGpsData(SHMUser user) {
		JSONObject data = new JSONObject();
		List<Double> gpsData = user.getLocateInfo();
		data.put("lng", gpsData.get(0));
		data.put("lat", gpsData.get(1));
		data.put("command", "GPS_DATA");
		data.put("uid", user.getUid());
		SendData(Constants.INVALID_CHAIR, data.toString());

		for (short i = 0; i < m_pIUserItem.length; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				if (m_pIUserItem[i].isAndroidUser == 0) {
					int uid = m_pIUserItem[i].dwUserID;
					SHMUser other = dthall.getInstance().getUserInfo(uid);
					if (other != null) {
						gpsData = other.getLocateInfo();
						data.put("uid", other.getUid());
						data.put("lng", gpsData.get(0));
						data.put("lat", gpsData.get(1));
						dthall.getInstance().onSend(user.getUid(), data.toString());
					}
				}
			}
		}
	}
	public void OnUserSit(int _Uid) {
		int bySeatID = FindSeat(_Uid);
		if (bySeatID < m_maxUserNum) {
			m_pIUserItem[bySeatID].cbOnline = Constants.US_NULL;
		}
		SHMUser user = dthall.getInstance().getUserInfo(_Uid);
		if (user != null) {
			for (int i = 0; i < m_maxUserNum; i++) {
				if (m_pIUserItem[i].dwUserID == _Uid) {
					m_pIUserItem[i].dwUserID = _Uid;
					// m_pIUserItem[i].lUserScore = user.getCoin();
					m_pIUserItem[i].wChairID = i;
					m_pIUserItem[i].dwFaceID = 0;
					m_pIUserItem[i].cbGender = user.getSex();
					m_pIUserItem[i].szNickName = user.getNickName(null);
					m_pIUserItem[i].szIP = user.getIP(null);
					m_pIUserItem[i].lUserCoin = user.getCoin(0);
					if(this.isDwcType()){
						m_pIUserItem[i].lUserRmb = user.getRmb1v1Value();
					}

					if(user.isAndroidPlayer()){
						m_pIUserItem[i].isAndroidUser = 2;
					}
					SUBCMD_S_Sit cmd = new SUBCMD_S_Sit();

					cmd.m_lUid = _Uid;
					cmd.m_wUserChairID = m_pIUserItem[i].wChairID;
					cmd.m_dwTableID = m_dwTableID;
					cmd.m_lUserScore = m_pIUserItem[i].lUserScore;
					cmd.m_cbGender = m_pIUserItem[i].cbGender;
					cmd.m_iAvatar = m_pIUserItem[i].dwFaceID;
					cmd.szNickName = user.getNickName(null);
					cmd.szIP = user.getIP(null);
					cmd.m_byRound = m_UserStatus;
					if(this.isGoldType())
						cmd.m_lUserCoin = user.getCoin(0);
					else if(this.isDwcType())
						cmd.m_lUserCoin = user.getRmb1v1Value();
					
					SendData(i, cmd.getJsonData());

					if (m_bGameStarted) {
						SendGameScene(_Uid, Constants.GS_PLAYING);
					} else {
						SendGameScene(_Uid, Constants.GS_FREE);
					}

					SendAvatar(m_pIUserItem[i].dwUserID);

					return;
				}
			}
			for (int i = 0; i < m_maxUserNum; i++) {
				if (m_pIUserItem[i].dwUserID == 0) {
					m_pIUserItem[i].dwUserID = _Uid;
					m_pIUserItem[i].lUserScore = 0;
					m_pIUserItem[i].wChairID = i;
					m_pIUserItem[i].dwFaceID = 0;
					m_pIUserItem[i].cbGender = user.getSex();
					m_pIUserItem[i].szNickName = user.getNickName(null);
					m_pIUserItem[i].szIP = user.getIP(null);
					m_pIUserItem[i].lUserCoin = user.getCoin(0);
					if(this.isDwcType()){
						m_pIUserItem[i].lUserRmb = user.getRmb1v1Value();
					}

					if(user.isAndroidPlayer()){
						m_pIUserItem[i].isAndroidUser = 2;
					}
					SUBCMD_S_Sit cmd = new SUBCMD_S_Sit();

					cmd.m_lUid = _Uid;
					cmd.m_wUserChairID = m_pIUserItem[i].wChairID;
					cmd.m_dwTableID = m_dwTableID;
					cmd.m_lUserScore = m_pIUserItem[i].lUserScore;
					cmd.m_cbGender = m_pIUserItem[i].cbGender;
					cmd.m_iAvatar = m_pIUserItem[i].dwFaceID;
					cmd.szNickName = user.getNickName(null);
					cmd.szIP = user.getIP(null);
					cmd.m_byRound = m_UserStatus;
					if(this.isGoldType())
						cmd.m_lUserCoin = user.getCoin(0);
					else if(this.isDwcType())
						cmd.m_lUserCoin = user.getRmb1v1Value();
					
					SendData(i, cmd.getJsonData());

					if (m_bGameStarted) {
						SendGameScene(_Uid, Constants.GS_PLAYING);
					} else {
						SendGameScene(_Uid, Constants.GS_FREE);
					}

					return;
				}
			}
		}

		return;
	}

	int FindSeat(long _Uid) {
		for (int bySeatID = 0; bySeatID < m_maxUserNum; bySeatID++) {
			if (m_pIUserItem[bySeatID].dwUserID == _Uid) {
				return bySeatID;
			}
		}
		return Constants.INVALID_CHAIR;
	}

	int GetPlayerCount() {
		int cntPlayer = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				cntPlayer++;
			}
		}
		return cntPlayer;
	}

	int GetRobotCount() {
		int cntPlayer = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].isAndroidUser == 1) {
				cntPlayer++;
			}
		}
		return cntPlayer;
	}

	public void OnUserStandUp(int _Uid,boolean leaveroom) {
		int wChairID = FindSeat(_Uid);
		
		if(m_bTableStarted == false && wChairID != 0 && leaveroom == true){
			SUBCMD_S_StandUp cmd = new SUBCMD_S_StandUp();
			cmd.m_lUid = _Uid;
			cmd.m_wUserChairID = wChairID;
			cmd.m_dwTableID = m_dwTableID;
			SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
		}


		if (m_bTableStarted == false && leaveroom == true) {
			if (wChairID >= 0 && wChairID < m_maxUserNum) {
				//如果是机器人，返回系统申请的资金
				if(m_pIUserItem[wChairID].isAndroidUser == 2){
					SHMUser user = dthall.getInstance().getUserInfo(m_pIUserItem[wChairID].dwUserID);
					if(user != null){
						double applyRmb = user.getApplyNum();
						if(applyRmb > m_pIUserItem[wChairID].lUserRmb){
							//亏了
							GoldMgr.getInstance().giveBackRobotRmb(m_pIUserItem[wChairID].lUserRmb);
							DwcRedisRecord.getInstance().addRmbGameInfo(UserRmbChange.reason108,m_pIUserItem[wChairID].lUserRmb - applyRmb);
						}else{
							//赚了
							GoldMgr.getInstance().giveBackRobotRmb(applyRmb);
							DwcRedisRecord.getInstance().addRmbGameInfo(UserRmbChange.reason108,m_pIUserItem[wChairID].lUserRmb - applyRmb);
						}
						onRemoveMineForUserLeave(m_pIUserItem[wChairID].dwUserID);
					}
					RobotMgr.getInstance().FreeRobot(m_pIUserItem[wChairID].dwUserID);
				}else if(m_pIUserItem[wChairID].isAndroidUser == 0){
					onRemoveMineForUserLeave(m_pIUserItem[wChairID].dwUserID);
				}
				m_pIUserItem[wChairID].Init();
				QpGameMgr.getInstance().OnRemoveUserRoom(_Uid);
			} else {
			}
		} else {
			if (wChairID < m_maxUserNum) {
				m_pIUserItem[wChairID].cbOnline = Constants.US_OFFLINE;
			}
		}	
	}
	public void SetParam(String szParam) {
		m_strParam = szParam;
		
		m_vecParam = m_strParam.split(";");
	}

	public void SetDesc(String szDesc) {
		m_strRoomDesc = szDesc;

	}

	boolean SendGameScene(int _Uid, int bGameStatus) {
		int wChairID = FindSeat(_Uid);
		if(wChairID >= m_maxUserNum)
		{
			return false;
		}
		if (m_strParam.length() > 0) {
			
			SUBCMD_S_Param cmd = new SUBCMD_S_Param();
			cmd.m_dwTableID = m_dwTableID;
			cmd.szParam = m_strParam;
			cmd.jinerInfo = m_jinErStr;
			cmd.beiShuInfo = m_beiShuStr;
			if(this.isDwcType() && this.m_dwcKouYing != 0){
				cmd.dwcKouYingRate = m_dwcKouYingRate;
			}
			SendData(_Uid, cmd.getJsonData());
		}
		
		int cntUser = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				cntUser++;
			}
		}
		{
			SUBCMD_S_Table cmd = new SUBCMD_S_Table();
			cmd.m_dwTableID = m_dwTableID;// ����ID
			cmd.m_bGameStarted = m_bGameStarted ? 1 : 0;// �Ƿ�ʼ
			cmd.m_bTableStarted = m_bTableStarted ? 1 : 0;// �Ƿ�ʼ
			cmd.m_byRound = m_byRound;
			cmd.m_byMaxRound = m_byMaxRound;
			cmd.m_cntUser = cntUser;// ���
			cmd.m_cntLookon = 1;// ����
			Constants.memset(cmd.m_seatInfo, 0, Constants.sizeof(cmd.m_seatInfo));

			cmd.m_seatInfo[0].m_lUid = m_pIUserItem[wChairID].dwUserID;// UID
			cmd.m_seatInfo[0].m_iTotalCoin = m_pIUserItem[wChairID].lUserScore;// COIN
			cmd.m_seatInfo[0].m_NickName = m_pIUserItem[wChairID].szNickName;// NICKNAME
			cmd.m_seatInfo[0].m_iBetCoin = 0;//
			cmd.m_seatInfo[0].m_cbGender = m_pIUserItem[wChairID].cbGender;
			cmd.m_seatInfo[0].m_iAvatar = m_pIUserItem[wChairID].dwFaceID;//
			cmd.m_seatInfo[0].m_cbUserStatus = m_pIUserItem[wChairID].cbUserStatus;// �û�״̬
			cmd.m_seatInfo[0].m_iVipLevel = m_pIUserItem[wChairID].cbVipLevel;// VIP
																		// LEVEL
			cmd.m_seatInfo[0].m_iTitle = 0;// �ƺ�
			cmd.m_seatInfo[0].m_isLookon = 0;// �Ƿ����
			cmd.m_seatInfo[0].szIP = m_pIUserItem[wChairID].szIP;// NICKNAME
			if(this.isGoldType())
				cmd.m_seatInfo[0].m_iTotalCoin = m_pIUserItem[wChairID].lUserCoin;
			else if(this.isDwcType())
				cmd.m_seatInfo[0].m_iTotalCoin = m_pIUserItem[wChairID].lUserRmb;

			SendData(_Uid, cmd.getJsonData());
		}
		
		//send当前红包
		sendCurrRed(wChairID);
		return true;
	}
	void OnEventGameStart() {
		Init(Constants.INIT_NEWROUND);
		if(m_byRound == 0)
			m_byRound = 1;
		OnRoundInfoChange();
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				m_pIUserItem[i].cbUserStatus = Constants.US_PLAY;
			}
		}
		m_bTableStarted = true;
		m_bGameStarted = true;
	}
	public void DoDismissRoomByOverTime(){
		OnEventGameEnd(0, Constants.GAME_END_DISMISS);
	}
	void OnEventGameEnd(int bySeatID,int cbReason){
		if(isZuJuType()){
			OnEventGameEndZuJu(bySeatID,cbReason);
		}else if(isGoldType()){
			onEventGameEndGold(bySeatID,cbReason);
		}else if(isDwcType()){
			onEventGameEndDwc(bySeatID,cbReason);
		}
	}
	void onEventGameEndDwc(int bySeatID, int cbReason) {
	
	}
	void onEventGameEndGold(int bySeatID, int cbReason) {
	
	}
	void OnEventGameEndZuJu(int bySeatID, int cbReason) {
	
	}

	static int log_counter = 0;

	
	int GetNextUser(int bySeatID)
	{
		int wNextUser = 0;
		for (int i = 1; i <= m_maxUserNum; i++) {
			wNextUser = (bySeatID + i) % m_maxUserNum;
			if (m_pIUserItem[wNextUser].dwUserID > 0) {
				return wNextUser;
			}
			
		}
		return 0;
	}
	public void sendCurrRed(int seat){
		if(this.m_currMine == null || m_curStage.equals("stage_jiesuan")){
			SUBCMD_S_NewRed cmd = new SUBCMD_S_NewRed();
			cmd.headurl = "";
			cmd.jiner = 0;
			cmd.name = "";
			cmd.rednum = 0;
			cmd.uid = 0;
			cmd.liehao = 0;
			String data = cmd.getJsonData();
			SendData(seat,data);
			return;
		}
		SUBCMD_S_NewRed cmd = new SUBCMD_S_NewRed();
		cmd.headurl = dthall.getInstance().Handle_OnGetUserAvatar(m_currMine.m_mineInfo.m_lUid);
		cmd.jiner = (int)m_currMine.m_mineInfo.m_redRmb;
		cmd.name = m_currMine.m_mineInfo.m_name;
		cmd.rednum = m_currMine.m_currnum;
		cmd.uid = m_currMine.m_mineInfo.m_lUid;
		cmd.liehao = m_currMine.m_mineInfo.m_leiHao;
		String data = cmd.getJsonData();
		SendData(seat,data);
	}
	public void sendCurrRed(){
		if(this.m_currMine == null){
			SUBCMD_S_NewRed cmd = new SUBCMD_S_NewRed();
			cmd.headurl = "";
			cmd.jiner = 0;
			cmd.name = "";
			cmd.rednum = 0;
			cmd.uid = 0;
			cmd.liehao = 0;
			String data = cmd.getJsonData();
			SendData(Constants.INVALID_CHAIR,data);
			return;
		}
		SUBCMD_S_NewRed cmd = new SUBCMD_S_NewRed();
		cmd.headurl = dthall.getInstance().Handle_OnGetUserAvatar(m_currMine.m_mineInfo.m_lUid);
		cmd.jiner = (int)m_currMine.m_mineInfo.m_redRmb;
		cmd.name = m_currMine.m_mineInfo.m_name;
		cmd.rednum = m_currMine.m_mineInfo.m_redNum;
		cmd.uid = m_currMine.m_mineInfo.m_lUid;
		cmd.liehao = m_currMine.m_mineInfo.m_leiHao;
		String data = cmd.getJsonData();
		SendData(Constants.INVALID_CHAIR,data);
	}
	public long currDealTime = 0;
	void onRobotDrawRed(int num,int randomlimit){
		for(int i = 0;i < num;i++){
			if(CommonDef.getRandomInt(100) > randomlimit){
				IServerUserItem robot = getRandRobot();
				if(robot != null){
					String[] vec = new String[2];
					vec[0] = "kaired";
					vec[1] = "1";
					Handle_onKaiRed(robot.dwUserID,vec);										
				}
			}
		}
	}
	void OnDealAI(float dt) {
		//全部是机器人则不处理
		int currRealCnt = 0;
		for(int i = 0;i < this.m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 0){
				currRealCnt++;
			}
		}
		if(currRealCnt == 0)
			return;
		if(m_curStage.equals("stage_kaijiang")){
			currDealTime--;
			if(currDealTime == 0){
				//时间到，开始处理红包
				m_curStage = "stage_jiesuan";
				currDealTime = 3;
				Handle_OnJieSuan();
			}else{
				//机器人自动抢红包
				//真人数量太多就不处理了
				int realCnt = 0;
				for(int i = 0;i < this.m_maxUserNum;i++){
					if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 0 && m_pIUserItem[i].lUserRmb > 15){
						realCnt++;
					}
				}
				if(realCnt < 10 && m_needRobotDraw){
					if(m_guize.equals("mode1")){
						if(currDealTime == 4){
							if(m_currMine.m_currnum > 5){
								//抢
								onRobotDrawRed(1,60);
							}
						}else if(currDealTime == 3){
							if(m_currMine.m_currnum > 3){
								//抢
								onRobotDrawRed(3,60);
							}
						}else if(currDealTime == 2){
							if(m_currMine.m_currnum > 2){
								//抢
								onRobotDrawRed(3,60);
							}
						}else if(currDealTime == 1){
							if(m_currMine.m_currnum > 1){
								//抢
								onRobotDrawRed(m_currMine.m_currnum,60);
							}
						}
					}else{
						if(currDealTime == 4){
							if(m_currMine.m_currnum > 5){
								//抢
								onRobotDrawRed(1,70);
							}
						}else if(currDealTime == 3){
							if(m_currMine.m_currnum > 3){
								//抢
								onRobotDrawRed(3,70);
							}
						}else if(currDealTime == 2){
							if(m_currMine.m_currnum > 2){
								//抢
								onRobotDrawRed(3,70);
							}
						}else if(currDealTime == 1){
							if(m_currMine.m_currnum > 1){
								//抢
								onRobotDrawRed(1,70);
							}
						}
					}	
				}				
			}
		}else if(m_curStage.equals("stage_jiesuan")){
			currDealTime--;
			if(currDealTime == 0){
				//申请下一个红包
				MineInfo newMine = applyNextRed();
				if(newMine != null){
					if(this.m_currMine == null){
						this.m_currMine = new OpenRedInfo();
					}
					this.m_currMine.m_drawedInfo.clear();
					this.m_currMine.m_mineInfo = newMine;
					this.m_currMine.m_leftRmb = newMine.m_redRmb;
					this.m_currMine.m_currnum = newMine.m_redNum;
					this.m_currMine.m_getLeiNum = 0;
					//send 所有用户
					sendCurrRed();
					m_curStage = "stage_kaijiang";
					if(m_guize.equals("mode1")){
						currDealTime = 7;
					}else{
						currDealTime = 10;
					}
					addRobotRed();
				}else{
					//没有红包
					for(int i = 0;i < 5;i++)
						addRobotRed();
					currDealTime = 3;
				}
			}
		}
	}

	public  long currDealTime1 = 0;
	public void OnDeal(int dt) {
		if(currDealTime1 == 0){
			currDealTime1 = System.currentTimeMillis();
		}else{
			long time = System.currentTimeMillis();
			if((time - currDealTime1) >= 1000){
				currDealTime1 = time;
			}else{
				return;
			}
		}
		OnDealAI(dt);
		//手动调用添加机器人
		DoAddRobotPlayer();
		if(m_clubOwnerId == 0 && CommonDef.getRandomInt(500) < (8 + CommonDef.getRandomInt(10))){
			int index = CommonDef.getRandomInt(30);
			for(int i = 0;i < this.m_maxUserNum;i++){
				if(i >= index && m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 2){
					SHMUser user = dthall.getInstance().getUserInfo(m_pIUserItem[i].dwUserID);
					if(user == null)
						break;
					String chat = RobotMgr.getInstance().getRobotChat();
					if(hasSuchChat(chat)){
						break;
					}
					SUBCMD_S_Chat cmd = new SUBCMD_S_Chat();
					cmd.m_lUid = m_pIUserItem[i].dwUserID;
					cmd.m_wUserChairID = i;
					cmd.szContent = chat;
					cmd.name = user.getNickName(null);

					SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
					break;
				}
			}
		}
	}
	public void DoAddRobotPlayer(){
		if(m_clubOwnerId != 0)
			return;
		int robotcnt = 0;
		int realuser = 0;
		for(int i = 0;i < this.m_maxUserNum;i++){
			if(m_pIUserItem[i].isAndroidUser == 2){
				robotcnt++;
			}
			if(m_pIUserItem[i].dwUserID > 0){
				realuser++;
			}
		}
		if(realuser > 20){
			return;
		}
		if(robotcnt < 35){
			if(CommonDef.getRandomInt(100) < 20){
				Robot robot = RobotMgr.getInstance().AllocRobot();
				int robot_uid = robot.uid;				
				
				SHMUser user = dthall.getInstance().getUserInfo(robot_uid);
				if(user == null){
					setNeedRobot(false,0);
					return;
				}
				double robot_rmb = RobotMgr.getInstance().getRandRobotGold(10,3);
				robot_rmb += Math.random() * 2;
				BigDecimal b = new BigDecimal(robot_rmb);
				robot_rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				double rmb = GoldMgr.getInstance().applyRobotRmb(robot_rmb);
				if(rmb == 0){
					//申请不到足够rmb
					setNeedRobot(false,0);
					return;
				}
				user.setRMb1v1Value(rmb);
				user.setApplyNum(rmb);
				OnUserSit(robot_uid);
				OnUserSit(robot_uid);
			}
		}
		if(robotcnt >= 15){
			//随机一个而机器人退出
			if(CommonDef.getRandomInt(100) < 15){
				int index = CommonDef.getRandomInt(20);
				
				for(int i = 0;i < this.m_maxUserNum;i++){
					if(m_pIUserItem[i].isAndroidUser == 2 && i > index){
						OnUserStandUp(m_pIUserItem[i].dwUserID,true);
						break;
					}
				}
			}
		}
	}
	List<String> m_allSendChats = new ArrayList<String>();
	boolean hasSuchChat(String chat){
		boolean has = false;
		for(int i = 0;i < this.m_allSendChats.size();i++){
			if(chat.equals(this.m_allSendChats.get(i))){
				has = true;
				break;
			}
		}
		if(has){
			return true;
		}
		this.m_allSendChats.add(chat);
		return false;
	}
	static int randRobotIndex = 999;

	void AddRobot() {

	}

	void Handle_onJoin(int _Uid, String vecArg[]) {
		int bySeatID = FindSeat(_Uid);
		if (bySeatID < m_maxUserNum) {
			m_pIUserItem[bySeatID].cbOnline = Constants.US_NULL;
		}

		SUBCMD_S_Join cmd = new SUBCMD_S_Join();

		String sData = cmd.getJsonData();
		SendData(_Uid, sData);
	}

	void Handle_onReady(int _Uid, String vecArg[]) {
		if (m_bGameStarted == true) {
			return;
		}
		int bySeatID = FindSeat(_Uid);
		if (bySeatID < m_maxUserNum) {
			m_pIUserItem[bySeatID].cbUserStatus = Constants.US_READY;
			m_UserStatus[bySeatID] = Constants.US_READY;
		}
		int roomUserNumber = 0;
		UserCntReady = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].cbUserStatus == Constants.US_READY) {
				UserCntReady++;
			}
			if(m_pIUserItem[i].wChairID>=0){
				roomUserNumber++;
			}
		}
		
		SUBCMD_S_Ready cmd = new SUBCMD_S_Ready();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = bySeatID;
		cmd.m_dwTableID = m_dwTableID;
		cmd.m_byRound = m_UserStatus;
		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
		
		if(UserCntReady==roomUserNumber){
			OnEventGameStart();
		}
	}

	void Handle_onRobot(int _Uid, String vecArg[]) {
		if (m_bGameStarted == true) {
			return;
		}
		int bySeatID = FindSeat(_Uid);
		if (bySeatID < m_maxUserNum) {
			m_pIUserItem[bySeatID].cbUserStatus = Constants.US_READY;
		}
		int cntPlayer = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID > 0) {
				cntPlayer++;
			}
		}
		if (cntPlayer < m_maxUserNum) {
			for (int i = 0; i < m_maxUserNum - cntPlayer; i++) {
				AddRobot();
			}
		}
	}

	void Handle_onBiaoQing(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		if (vecArg.length < 2)
			return;
		int index = Constants.atoi(vecArg[1]);

		SUBCMD_S_BiaoQing cmd = new SUBCMD_S_BiaoQing();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = wChairID;
		cmd.m_iBiaoQingIndex = index;

		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
	}

	void Handle_onYuYin(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		if (vecArg.length < 2)
			return;
		int index = Constants.atoi(vecArg[1]);

		SUBCMD_S_YuYin cmd = new SUBCMD_S_YuYin();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = wChairID;
		cmd.m_iYuYinIndex = index;

		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
	}

	void Handle_onSongLi(int _Uid, String vecArg[]) {
	}

	void Handle_onChat(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		if (vecArg.length < 2)
			return;
		String strContent = vecArg[1];

		SUBCMD_S_Chat cmd = new SUBCMD_S_Chat();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = wChairID;
		cmd.szContent = strContent;
		cmd.name = m_pIUserItem[wChairID].szNickName;
		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
	}

	void Handle_onVoice(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		if (vecArg.length < 3)
			return;
		int seconds = Constants.atoi(vecArg[1]);
		String strVoiceURL = vecArg[2];

		SUBCMD_S_Voice cmd = new SUBCMD_S_Voice();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = wChairID;
		cmd.seconds = seconds;
		cmd.szVoiceURL = strVoiceURL;

		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
	}
	void Handle_onExpr(int _Uid, String[] vecArg) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		int uid1 = Integer.parseInt(vecArg[1]);
		int uid2 = Integer.parseInt(vecArg[2]);
		int index = Integer.parseInt(vecArg[3]);
		
		SUBCMD_S_ExprMsg cmd = new SUBCMD_S_ExprMsg();
		cmd.m_uid1 = uid1;
		cmd.m_uid2 = uid2;
		cmd.m_index = index;
		
		SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
	}
	void Handle_onVoiceMsg(int _Uid, String[] vecArg) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		float seconds = Float.parseFloat(vecArg[1]);
		
		SUBCMD_S_VoiceMsg cmd = new SUBCMD_S_VoiceMsg();
		cmd.m_lUid = _Uid;
		cmd.m_wUserChairID = wChairID;
		cmd.seconds = seconds;
		
		cmd.data = vecArg[2];
		cmd.m_maxClip = Integer.parseInt(vecArg[3]);
		cmd.m_currClip = Integer.parseInt(vecArg[4]);
		SendData(Constants.INVALID_CHAIR,cmd.getJsonData());
	}
	void Handle_onTryDismissRoom(int _Uid, String vecArg[]) {
		int bySeatID = FindSeat(_Uid);
		if (bySeatID == Constants.INVALID_CHAIR) {
			return;
		}
		if (vecArg.length < 2)
			return;
		String attachInfo = vecArg[1];
		if(attachInfo.equals("fzquit")){
			//房主请求直接退出
			OnEventGameEnd(0, Constants.GAME_END_DISMISS);
			return;
		}
		int cntUser = 0;
		int cntOnline = 0;
		int cntOffline = 0;
		for (int i = 0; i < m_maxUserNum; i++) {
			if (m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 0 && m_pIUserItem[i].cbOnline == 0) {
				cntUser++;
			}
		}
		for (int i = 0; i < m_maxUserNum; i++)
		{
			if (m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 0)
			{
				if (m_pIUserItem[i].cbOnline == Constants.US_OFFLINE)
				{
					cntOffline++;
				}
				else{
					cntOnline++;
				}
			}
		}		
		if (cntUser > 1) {
			if (m_dismissTimer == 0) {
				m_dismissTimer = Constants.time(null);
			}

			SUBCMD_S_TryDismissRoom cmd = new SUBCMD_S_TryDismissRoom();
			cmd.lUid = _Uid;
			cmd.dwTableID = m_dwTableID;
			cmd.szNickName = m_pIUserItem[bySeatID].szNickName;

			SendData(Constants.INVALID_CHAIR, cmd.getJsonData());
			
			if (cntOnline == 1)
			{
				OnEventGameEnd(0, Constants.GAME_END_DISMISS);

				m_dismissTimer = 0;
			}			
		} else {
			OnEventGameEnd(0, Constants.GAME_END_DISMISS);
		}

	}

	void Handle_onAgreeDismissRoom(int _Uid, String vecArg[]) {
	
	}

	void Handle_onRefuseDismissRoom(int _Uid, String vecArg[]) {
	
	}

	void Handle_onStart(int _Uid, String vecArg[]) {
		if (vecArg.length < 2)
			return;

		int bySeatID = FindSeat(_Uid);
		if (m_bTableStarted == false && bySeatID == 0 && GetPlayerCount() > 1) {
			OnEventGameStart();
		}
	}
	public double applyZhengShuRmb(){
		int rate = CommonDef.getRandomInt(100);
		if(rate >= 75){
			//完全随机
			return CommonDef.getRandomInt((int)(m_currMine.m_leftRmb - 1));
		}else if(rate >= 50){
			//按照红包数目平均来
			double aver = m_currMine.m_leftRmb / m_currMine.m_currnum;
			double slimit = aver * 1.5;
			if(slimit > (m_currMine.m_leftRmb - 1))
				slimit = m_currMine.m_leftRmb - 1;
			return CommonDef.randInt((int)(aver * 0.5),(int)(slimit));
		}else if(rate >= 25){
			//按照2/3来
			double fund3_2 = m_currMine.m_leftRmb * 2 / 3;
			return CommonDef.getRandomInt((int)(fund3_2 - 1));
		}else{
			//按照1/3来
			double fund3_1 = m_currMine.m_leftRmb * 1 / 3;
			return CommonDef.getRandomInt((int)(fund3_1 - 1));
		}
	}
	public double applyAdaptRmb(int seatId){
		IServerUserItem user = m_pIUserItem[seatId];
		if(m_currMine.m_mineInfo.m_isAndroidUser == 2){
			//机器人发的红包,机器人领取也随机中
			boolean isZhongLei = false;
			if(m_currMine.m_getLeiNum == 0){
				if(CommonDef.getRandomInt(100) > 70){
					isZhongLei = true;
				}
			}else if(m_currMine.m_getLeiNum == 1){
				if(CommonDef.getRandomInt(100) > 85){
					isZhongLei = true;
				}
			}else if(m_currMine.m_getLeiNum > 1){
				if(CommonDef.getRandomInt(100) > 95){
					isZhongLei = true;
				}
			}
			if(!isZhongLei && user.isAndroidUser == 0){
				//真人不中则再随机一次
				if(CommonDef.getRandomInt(100) > 95){
					isZhongLei = true;
				}
			}
			boolean isHack = DwcRedisRecord.getInstance().isSlhbHackUser(user.dwUserID);
			if(isHack){
				isZhongLei = false;
			}
			if(isZhongLei){
				double rmb = applyZhengShuRmb();
				rmb += CommonDef.getRandomInt(10) * 0.1;
				rmb += m_currMine.m_mineInfo.m_leiHao * 0.01;
				//处理成小数点2位
				BigDecimal b = new BigDecimal(rmb);
				rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				m_currMine.m_currnum--;
				m_currMine.m_leftRmb -= rmb;
				BigDecimal b1 = new BigDecimal(m_currMine.m_leftRmb);
				m_currMine.m_leftRmb = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				return rmb;
			}else{
				//随机分配
				double rmb = 0.0;
				while(true){
					rmb = applyZhengShuRmb();
					rmb +=  CommonDef.getRandomInt(100) * 0.01;
					//处理成小数点2位
					BigDecimal b = new BigDecimal(rmb);
					rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
					if(!isGetLei(rmb)){
						break;
					}
				}
				m_currMine.m_currnum--;
				m_currMine.m_leftRmb -= rmb;
				BigDecimal b1 = new BigDecimal(m_currMine.m_leftRmb);
				m_currMine.m_leftRmb = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				return rmb;
			}
		}else{
			//真人的发的红包
			boolean isZhongLei = false;
			if(m_currMine.m_getLeiNum == 0){
				if(CommonDef.getRandomInt(100) > 70){
					isZhongLei = true;
				}
			}else if(m_currMine.m_getLeiNum == 1){
				if(CommonDef.getRandomInt(100) > 85){
					isZhongLei = true;
				}
			}else if(m_currMine.m_getLeiNum > 1){
				if(CommonDef.getRandomInt(100) > 95){
					isZhongLei = true;
				}
			}
			if(user.isAndroidUser == 2){
				//机器人领取再次随机
				if(isZhongLei){
					if(CommonDef.getRandomInt(100) > 95){
						isZhongLei = true;
					}else{
						isZhongLei = false;
					}
				}
			}else{
				//真人领取
			}
			boolean isHack = DwcRedisRecord.getInstance().isSlhbHackUser(user.dwUserID);
			if(isHack){
				isZhongLei = false;
			}
			if(isZhongLei){
				double rmb = applyZhengShuRmb();
				rmb += CommonDef.getRandomInt(10) * 0.1;
				rmb += m_currMine.m_mineInfo.m_leiHao * 0.01;
				//处理成小数点2位
				BigDecimal b = new BigDecimal(rmb);
				rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				m_currMine.m_currnum--;
				m_currMine.m_leftRmb -= rmb;
				BigDecimal b1 = new BigDecimal(m_currMine.m_leftRmb);
				m_currMine.m_leftRmb = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				return rmb;
			}else{
				//随机分配
				double rmb = 0.0;
				while(true){
					rmb = applyZhengShuRmb();
					rmb +=  CommonDef.getRandomInt(100) * 0.01;
					//处理成小数点2位
					BigDecimal b = new BigDecimal(rmb);
					rmb = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
					if(!isGetLei(rmb)){
						break;
					}
				}
				m_currMine.m_currnum--;
				m_currMine.m_leftRmb -= rmb;
				BigDecimal b1 = new BigDecimal(m_currMine.m_leftRmb);
				m_currMine.m_leftRmb = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
				return rmb;
			}
		}
	}
	boolean isGetLei(double rmb){
		if(m_currMine == null || m_currMine.m_mineInfo == null)
			return false;
		rmb *= 100;
		BigDecimal b1 = new BigDecimal(rmb);
		rmb = b1.setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue(); 
		rmb = rmb % 10;
		if(rmb == m_currMine.m_mineInfo.m_leiHao)
			return true;
		else
			return false;
	}
	void Handle_onRobotKaiRed(){
		if(m_clubOwnerId != 0)
			return;
		if(this.m_currMine == null || this.m_currMine.m_mineInfo == null){
			return;
		}
		if(this.m_currMine.m_currnum == 0 || this.m_currMine.m_leftRmb == 0.0){
			return;
		}
		//找到一个合适的机器人
		int bySeatID = 0;
		int repeat = 10;
		int robotCount = 0;
		for(int i = 0;i < this.m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 2){
				robotCount++;
			}
		}
		while(bySeatID > 0 && repeat > 0 && robotCount > 0){
			repeat--;
			int rindex = CommonDef.getRandomInt(robotCount);
			int count = 0;
			for(int i = 0;i < this.m_maxUserNum;i++){
				if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 2){
					count++;
					if(count == rindex && m_pIUserItem[i].dwUserID != m_currMine.m_mineInfo.m_lUid 
							&& m_pIUserItem[i].lUserRmb > (m_currMine.m_mineInfo.m_redRmb * m_currMine.m_mineInfo.m_beishu)){
						bySeatID = i;
						for(int k = 0;k < m_currMine.m_drawedInfo.size();k++){
							if(m_currMine.m_drawedInfo.get(k).m_lUid == m_pIUserItem[i].dwUserID){
								//此用户已经领过了
								bySeatID = 0;
								break;
							}
						}
						if(bySeatID != 0)
							break;
					}
				}
			}
		}
		double drawRmb = 0.0;
		if(m_currMine.m_leftRmb == 1){
			//只剩一次了
			if(m_currMine.m_leftRmb < 80.0 && isGetLei(m_currMine.m_leftRmb)){
				//数额较小且中雷
				return;
			}
			drawRmb = m_currMine.m_leftRmb;
			m_currMine.m_currnum = 0;
		}else{
			drawRmb = applyAdaptRmb(bySeatID);
		}
		DrawInfo draw = new DrawInfo();
		draw.m_drawRmb = drawRmb;
		draw.m_isAndroidUser = 0;
		draw.m_lUid = m_pIUserItem[bySeatID].dwUserID;
		draw.m_name = m_pIUserItem[bySeatID].szNickName;
		m_currMine.m_drawedInfo.add(draw);
		//send
		SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
		open.uid = m_pIUserItem[bySeatID].dwUserID;
		open.name = m_pIUserItem[bySeatID].szNickName;
		open.success = 1;
		open.isLei = isGetLei(drawRmb) ? 1 : 0;
		open.leftRed = m_currMine.m_currnum;
		open.redJiner = drawRmb;
		if(open.isLei == 1){
			double pei = m_currMine.m_mineInfo.m_beishu * m_currMine.m_mineInfo.m_redRmb;
			pei -= drawRmb;
			BigDecimal b = new BigDecimal(pei);
			pei = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
			open.peiJiner = pei;
		}else{
			open.peiJiner = 0;
		}
		String data = open.getJsonData();
		SendData(Constants.INVALID_CHAIR,data);
		if(m_currMine.m_currnum == 0){
			m_curStage = "stage_jiesuan";
			currDealTime = 3;
		}
	}
	void Handle_onKaiRed(int _Uid, String vecArg[]) {
		if (vecArg.length < 2)
			return;
		if(!m_curStage.equals("stage_kaijiang")){
			return;
		}
		int bySeatID = FindSeat(_Uid);
		if (bySeatID == Constants.INVALID_CHAIR) {
			return;
		}
		if(this.m_currMine == null || this.m_currMine.m_mineInfo == null){
			SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
			open.uid = _Uid;
			open.name = m_pIUserItem[bySeatID].szNickName;
			open.success = 0;
			open.reason = "当前红包为空!";
			String data = open.getJsonData();
			SendData(bySeatID,data);
			return;
		}
		if(this.m_currMine.m_currnum == 0 || this.m_currMine.m_leftRmb == 0.0){
			SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
			open.uid = _Uid;
			open.name = m_pIUserItem[bySeatID].szNickName;
			open.success = 0;
			open.reason = "红包已被领完!";
			String data = open.getJsonData();
			SendData(bySeatID,data);
			return;
		}
		if(m_pIUserItem[bySeatID].lUserRmb < (m_currMine.m_mineInfo.m_redRmb * m_currMine.m_mineInfo.m_beishu)){
			SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
			open.uid = _Uid;
			open.name = m_pIUserItem[bySeatID].szNickName;
			open.success = 0;
			open.reason = "您的资金不足,无法点开红包!";
			String data = open.getJsonData();
			SendData(bySeatID,data);
			return;
		}
		//屏蔽掉能否领取自己的红包
		if(!GoldMgr.getInstance().getSLHBCanDrawSelf() && m_pIUserItem[bySeatID].dwUserID == m_currMine.m_mineInfo.m_lUid){
			SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
			open.uid = _Uid;
			open.name = m_pIUserItem[bySeatID].szNickName;
			open.success = 0;
			open.reason = "您不能领取自己发的扫雷红包!";
			String data = open.getJsonData();
			SendData(bySeatID,data);
			return;
		}
		for(int i = 0;i < m_currMine.m_drawedInfo.size();i++){
			if(_Uid == m_currMine.m_drawedInfo.get(i).m_lUid){
				SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
				open.uid = _Uid;
				open.name = m_pIUserItem[bySeatID].szNickName;
				open.success = 0;
				open.reason = "您已经领过此红包了!";
				String data = open.getJsonData();
				SendData(bySeatID,data);
				return;
			}
		}
		//领取一次
		double drawRmb = 0.0;
		if(m_currMine.m_currnum == 1){
			//只剩一次了
			drawRmb = m_currMine.m_leftRmb;
			m_currMine.m_currnum = 0;
		}else{
			drawRmb = applyAdaptRmb(bySeatID);
		}
		DrawInfo draw = new DrawInfo();
		draw.m_drawRmb = drawRmb;
		draw.m_isAndroidUser = 0;
		draw.m_lUid = _Uid;
		draw.m_name = m_pIUserItem[bySeatID].szNickName;
		m_currMine.m_drawedInfo.add(draw);
		//send
		SUBCMD_S_OpenRed open = new SUBCMD_S_OpenRed();
		open.uid = _Uid;
		open.name = m_pIUserItem[bySeatID].szNickName;
		open.success = 1;
		open.isLei = isGetLei(drawRmb) ? 1 : 0;
		open.leftRed = m_currMine.m_currnum;
		open.redJiner = drawRmb;
		open.headurl = dthall.getInstance().Handle_OnGetUserAvatar(_Uid);
		if(open.isLei == 1){
			double pei = m_currMine.m_mineInfo.m_beishu * m_currMine.m_mineInfo.m_redRmb;
			pei -= drawRmb;
			BigDecimal b = new BigDecimal(pei);
			pei = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 
			open.peiJiner = pei;
		}else{
			open.peiJiner = 0;
		}
		String data = open.getJsonData();
		SendData(Constants.INVALID_CHAIR,data);
		if(m_currMine.m_currnum == 0){
			m_curStage = "stage_jiesuan";
			Handle_OnJieSuan();
			currDealTime = 3;
		}
	}
	void Handle_onMaiLei(int _Uid, String vecArg[]){
		if (vecArg.length < 3)
			return;
		int bySeatID = FindSeat(_Uid);
		if (bySeatID == Constants.INVALID_CHAIR) {
			return;
		}
		double rmb = Double.parseDouble(vecArg[1]);
		int leihao = Integer.parseInt(vecArg[2]);
		if(rmb > m_pIUserItem[bySeatID].lUserRmb){			
			SUBCMD_S_MaiLei cmd = new SUBCMD_S_MaiLei();
			cmd.success = 0;
			cmd.reason = "您的资金不足，无法埋雷";
			SendData(bySeatID,cmd.getJsonData());
			return;
		}
		MineInfo mine = new MineInfo();
		mine.m_redRmb = rmb;
		mine.m_isAndroidUser = 0;
		mine.m_lUid = m_pIUserItem[bySeatID].dwUserID;
		mine.m_name = m_pIUserItem[bySeatID].szNickName;
		mine.m_leiHao = leihao;
		if(m_guize.equals("mode1")){
			mine.m_redNum = 7;
			mine.m_beishu = 1.5;
		}else if(m_guize.equals("mode2")){
			mine.m_redNum = 10;
			mine.m_beishu = 1;
		}
		addMine(mine);
		SUBCMD_S_MaiLei cmd = new SUBCMD_S_MaiLei();
		cmd.success = 1;
		SendData(bySeatID,cmd.getJsonData());
		return;
	}
	void Handle_onLeiList(int _Uid, String vecArg[]){
		if (vecArg.length < 2)
			return;
		int bySeatID = FindSeat(_Uid);
		if (bySeatID == Constants.INVALID_CHAIR) {
			return;
		}
		JSONObject rev = new JSONObject();
		rev.put("command", "dwc_lei_list");
		List<String> infos = new ArrayList<String>();
		for(int i = 0;i < m_applyMines.size();i++){
			MineInfo mine = m_applyMines.get(i);
			JSONObject json = new JSONObject();
			json.put("name", mine.m_name);
			json.put("headUrl",dthall.getInstance().Handle_OnGetUserAvatar(mine.m_lUid));
			json.put("rmb", mine.m_redRmb);
			infos.add(json.toString());
		}
		rev.put("data", infos);
		SendData(bySeatID,rev.toString());
	}
	void Handle_onUserList(int _Uid, String vecArg[]){
		if (vecArg.length < 2)
			return;
		int bySeatID = FindSeat(_Uid);
		if (bySeatID == Constants.INVALID_CHAIR) {
			return;
		}
		JSONObject rev = new JSONObject();
		rev.put("command", "dwc_user_list");
		List<String> infos = new ArrayList<String>();
		for(int i = 0;i < this.m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0){				
				JSONObject json = new JSONObject();
				json.put("name", m_pIUserItem[i].szNickName);
				json.put("headUrl",dthall.getInstance().Handle_OnGetUserAvatar(m_pIUserItem[i].dwUserID));
				json.put("rmb", m_pIUserItem[i].lUserRmb);
				infos.add(json.toString());
			}
		}
		rev.put("data", infos);
		SendData(bySeatID,rev.toString());
	}
	void Handle_OnJieSuan(){
		//所有真金实际操作全部在这里
		//不中雷的全部按照赢家扣除模式
		//中雷的扣除
		SecShmUser zhuangUser = dthall.getInstance().getSecurityUserInfo(m_currMine.m_mineInfo.m_lUid);
		int zhuangSeat = FindSeat(m_currMine.m_mineInfo.m_lUid);
		//先扣除全部
		double zhuangTouRu = 0.0;
		zhuangTouRu -= m_currMine.m_mineInfo.m_redRmb;
		m_pIUserItem[zhuangSeat].lUserRmb -= m_currMine.m_mineInfo.m_redRmb;
		zhuangUser.getRmb1v1(-m_currMine.m_mineInfo.m_redRmb);
		UserRmbChange.handleRmbChangeWinLose(zhuangUser,-m_currMine.m_mineInfo.m_redRmb, UserRmbChange.reason108);
		//有剩余则加上
		if(m_currMine.m_leftRmb > 0){
			zhuangTouRu += m_currMine.m_leftRmb;
			m_pIUserItem[zhuangSeat].lUserRmb += m_currMine.m_leftRmb;
			zhuangUser.getRmb1v1(m_currMine.m_leftRmb);
			UserRmbChange.handleRmbChangeWinLose(zhuangUser,m_currMine.m_leftRmb, UserRmbChange.reason108);
		}
		double zhuangWon = 0.0;
		for(int i = 0;i < m_currMine.m_drawedInfo.size();i++){
			DrawInfo drawUser = m_currMine.m_drawedInfo.get(i);
			SecShmUser xianUser = dthall.getInstance().getSecurityUserInfo(drawUser.m_lUid);
			int xianSeat = FindSeat(drawUser.m_lUid);
			if(isGetLei(drawUser.m_drawRmb)){
				//中雷
				double pei = m_currMine.m_mineInfo.m_redRmb * m_currMine.m_mineInfo.m_beishu;
				pei -= drawUser.m_drawRmb;

				BigDecimal b = new BigDecimal(pei);
				pei = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
				if(pei > xianUser.getRmb1v1(0)){
					//最多赔完
					pei = xianUser.getRmb1v1(0);
				}
				
				//记录
				m_pIUserItem[xianSeat].lUserRmb -= pei;
				m_pIUserItem[zhuangSeat].lUserRmb += pei;
				zhuangUser.getRmb1v1(pei);
				xianUser.getRmb1v1(0 - pei);

				UserRmbChange.handleRmbChangeWinLose(zhuangUser,pei, UserRmbChange.reason108);
				UserRmbChange.handleRmbChangeWinLose(xianUser,-pei,UserRmbChange.reason108);
				zhuangWon += pei;
				if(m_pIUserItem[zhuangSeat].isAndroidUser == 2){
					//robot win & lost
					this.addRobotWinScore(pei);
				}
				if(m_pIUserItem[xianSeat].isAndroidUser == 2){
					//robot win & lost
					this.addRobotWinScore(-pei);
				}
				//记录业绩
				if(m_pIUserItem[zhuangSeat].isAndroidUser == 0){
					UserRedisInfo.addYeJiFanXian(m_pIUserItem[zhuangSeat].dwUserID,pei,m_clubOwnerId);
				}
				if(m_pIUserItem[xianSeat].isAndroidUser == 0){
					UserRedisInfo.addYeJiFanXian(m_pIUserItem[xianSeat].dwUserID,pei,m_clubOwnerId);
				}				
			}else{
				//不中雷，扣赢家
				double get = drawUser.m_drawRmb;
				//记录
				m_pIUserItem[xianSeat].lUserRmb += get;
				xianUser.getRmb1v1(get);

				UserRmbChange.handleRmbChangeWinLose(xianUser,get,UserRmbChange.reason108);
				if(m_pIUserItem[zhuangSeat].isAndroidUser == 2){
					//robot win & lost
					this.addRobotWinScore(get);
				}
				//业绩记录
				if(m_pIUserItem[zhuangSeat].isAndroidUser == 0){
					UserRedisInfo.addYeJiFanXian(m_pIUserItem[zhuangSeat].dwUserID,get,m_clubOwnerId);
				}
				if(m_pIUserItem[xianSeat].isAndroidUser == 0){
					UserRedisInfo.addYeJiFanXian(m_pIUserItem[xianSeat].dwUserID,get,m_clubOwnerId);
				}
				//只扣赢家的，输家输的不变
				if(get > 0){
					double kou = get * m_dwcKouYingRate;
					BigDecimal b = new BigDecimal(kou);
					kou = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
					//再次扣除需要
					xianUser.getRmb1v1(0 - kou);
					m_pIUserItem[xianSeat].lUserRmb -= kou;
					UserRmbChange.handleRmbChangeWinLose(xianUser,0 - kou, UserRmbChange.reason108);
					if(m_pIUserItem[xianSeat].isAndroidUser == 0){
						//只记录真人的
						//租赁记录
						UserRedisInfo.addKouYingFanXianForRent(m_pIUserItem[xianSeat].dwUserID,kou);
						double givesys = (1.0 - m_dwcKouYingFanliRate) * kou;
						double giveagent = m_dwcKouYingFanliRate * kou;
						BigDecimal b1 = new BigDecimal(givesys);
						givesys = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
						BigDecimal b2 = new BigDecimal(giveagent);
						giveagent = b2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
						UserRedisInfo.addKouYingFanXian(m_pIUserItem[xianSeat].dwUserID, giveagent);
						DwcRedisRecord.getInstance().addRmbGameInfo(UserRmbChange.reason108, givesys);
					}
				}
				//广播
				if(get > GoldMgr.getInstance().getRmbBroadCastLimit()){
					//大于进行广播
					net.sf.json.JSONObject broad = new net.sf.json.JSONObject();
					broad.put("command","public_logic_broad_user");
					broad.put("value1", m_pIUserItem[xianSeat].szNickName);
					broad.put("value2", "扫雷红包");
					broad.put("value3", get);
					broad.put("value4", "");
					AdminRedis.getInstance().pubAdminSubMsg(broad);
				}
				//记录战绩
				if(m_pIUserItem[xianSeat].isAndroidUser == 0){
					//只记录真人闲家
					JSONObject recordjson = new JSONObject();
					recordjson.put("gameName", "扫雷红包闲家");
					recordjson.put("roomId",this.GetID());
					recordjson.put("clubid",m_clubId);
					recordjson.put("clubownerid",m_clubOwnerId);
					recordjson.put("time", UserRedisInfo.getRecordTimeKey());
					recordjson.put("name0", m_pIUserItem[xianSeat].szNickName);
					recordjson.put("score0",get);
					recordjson.put("uid0",m_pIUserItem[xianSeat].dwUserID);
					DwcRedisRecord.getInstance().addZhanJi(recordjson);
				}
			}
		}
		if(zhuangWon > GoldMgr.getInstance().getRmbBroadCastLimit()){
			//大于进行广播
			net.sf.json.JSONObject broad = new net.sf.json.JSONObject();
			broad.put("command","public_logic_broad_user");
			broad.put("value1", m_pIUserItem[zhuangSeat].szNickName);
			broad.put("value2", "扫雷红包");
			broad.put("value3", zhuangWon);
			broad.put("value4", "");
			AdminRedis.getInstance().pubAdminSubMsg(broad);
		}
		//记录战绩
		JSONObject recordjson = new JSONObject();
		recordjson.put("gameName", "扫雷红包庄家");
		recordjson.put("roomId",this.GetID());
		recordjson.put("clubid",m_clubId);
		recordjson.put("clubownerid",m_clubOwnerId);
		recordjson.put("time", UserRedisInfo.getRecordTimeKey());
		recordjson.put("name0", m_pIUserItem[zhuangSeat].szNickName);
		recordjson.put("score0",zhuangWon + zhuangTouRu);
		recordjson.put("uid0",m_pIUserItem[zhuangSeat].dwUserID);
		DwcRedisRecord.getInstance().addZhanJi(recordjson);
		
		SUBCMD_S_JieSuan cmd = new SUBCMD_S_JieSuan();
		cmd.zhuangWin = zhuangWon;
		double bestWin = 0.0;
		for(int i = 0;i < m_currMine.m_drawedInfo.size();i++){
			if(!isGetLei(m_currMine.m_drawedInfo.get(i).m_drawRmb)){
				if(m_currMine.m_drawedInfo.get(i).m_drawRmb > bestWin){
					cmd.uidbest = m_currMine.m_drawedInfo.get(i).m_lUid;
					bestWin = 	m_currMine.m_drawedInfo.get(i).m_drawRmb;
				}
			}
		}
		dthall hall = dthall.getInstance();
		for(int i = 0;i < this.m_maxUserNum;i++){
			if(m_pIUserItem[i].dwUserID > 0 && m_pIUserItem[i].isAndroidUser == 0){
				cmd.myRmb = m_pIUserItem[i].lUserRmb;
				hall.onSend(m_pIUserItem[i].dwUserID, cmd.getJsonData());
			}
		}
	}
	MineInfo applyNextRed(){
		//申请下一个红包，检查用户是否在线了，检查用户当前的资金是否足够了
		m_robotDrawNum = 0;
		m_realDrawNum = 0;
		if(m_realDrawNum >= 5){
			m_needRobotDraw = false;
		}else{
			m_needRobotDraw = true;
		}
		if(m_applyMines.size() == 0)
			return null;
		MineInfo info = null;
		while(m_applyMines.size() > 0){
			info = m_applyMines.remove(0);
			for(int i = 0;i < this.m_maxUserNum;i++){
				if(m_pIUserItem[i].dwUserID == info.m_lUid){
					//用户在线
					if(m_pIUserItem[i].lUserRmb > info.m_redRmb)
						return info;
				}
			}
		}
		return null;
	}
	void Handle_onXiaZhu(int _Uid, String vecArg[]) {

	}
	
	public int FindSeat(int _Uid) {
		for (int bySeatID = 0; bySeatID < m_maxUserNum; bySeatID++) {
			if (m_pIUserItem[bySeatID].dwUserID == _Uid) {
				return bySeatID;
			}
		}
		return Constants.INVALID_CHAIR;
	}

	int random(int iMin, int iMax) {
		if(iMax <= iMin || iMax <= 0)
			return 0;
		Random ra = new Random();
		return ra.nextInt(iMax - iMin) + iMin;
	}

	public void memcpy(int[] o, int[] b, int l) {
		for (int i = 0; i < l; i++) {
			o[i] = b[i];
		}
	}
	public int m_DealTime = 0;

	public int getDealTime() {
		return 1000;
	}
	
	public boolean m_bRemove = false;

	public void DelayRemove() {
		m_bRemove = true;
	}

	public void ResetKillFlag() {
		m_bRemove = false;
	}

	public boolean ShouldBeRemoved() {
		return m_bRemove;
	}
	
	public void Handle_onLock(Integer lUid, String[] vecArg) {		
		if (vecArg.length < 2)
			return;
		if ( m_bTableStarted && m_pIUserItem[0].dwUserID == lUid) {
			int index = Constants.atoi(vecArg[1]);
			m_locked = index;			
			
		}
	}
	void Handle_InBack(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
				
		SUBCMD_S_InBack cmd = new SUBCMD_S_InBack();
		cmd.byActionUser = wChairID;
		SendData(Constants.INVALID_CHAIR,cmd.getJsonData());
	}

	void Handle_InFore(int _Uid, String vecArg[]) {
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		
		SUBCMD_S_InFore cmd = new SUBCMD_S_InFore();
		cmd.byActionUser = wChairID;
		SendData(Constants.INVALID_CHAIR,cmd.getJsonData());
	}
	void Handle_GameIap(int _Uid,String vecArg[]){
		int wChairID = FindSeat(_Uid);
		if (wChairID == Constants.INVALID_CHAIR) {
			return;
		}
		SHMUser user = dthall.getInstance().getUserInfo(_Uid);
		if(user == null){
			return;
		}
		SUBCMD_S_GameIap cmd = new SUBCMD_S_GameIap();
		cmd.uid = _Uid;
		cmd.seat = wChairID;
		cmd.coin = user.getCoin(0);
		SendData(Constants.INVALID_CHAIR,cmd.getJsonData());
	}
	@Override
	public String getRoomInfo() {
		return "";
	}
	
	public boolean isM_bGameStarted(){
		return m_bGameStarted;
	}
	
	@Override
	public int getPlayerCount() {
		return GetPlayerCount();
	}
	@Override
	public int getCostGem() {
		return 0;
	}
	@Override
	public int getStatus() {
		if(m_bTableStarted == false)
		{
			return 0;
		}
		return 1;
	}

	@Override
	public String getRoomDesc() {
		return null;
	}

	@Override
	public int getCellScore() {
		return 0;
	}

	@Override
	public int getMinScore() {
		return 0;
	}

	@Override
	public String getPayway() {
		return m_payWay;
	}

	@Override
	public String GetRoundInfo() {
		return "" + m_byRound + "/" +  m_byMaxRound;
	}
}
